const express = require('express');
const Entry_exams = require('../models/entry_exam');
const Stu_infos = require('../models/stu_infos');
const router = new express.Router();
// 测试当期的路由器模块有没有问题
/* router.get('/test',(req,res)=>{
    res.send('xx');
}) */
// 入学成绩的增删改查
router.post('/create_entry',async(req,res)=>{
    const score_entry = req.body;
    await Entry_exams.create(score_entry); 
    res.send('入学成绩提交成功！！')
})
router.post('/search_entry_stu_info',async(req,res)=>{
    // const stu_id = req.body.stu_id;
    const {stu_id} = req.body;
    console.log(stu_id);
    Stu_infos.aggregate([{"$lookup":{"from":'entry_exams',"localField":"stu_id","foreignField":"stu_id","as":"gerenxinxichengji"}},{"$lookup":{"from":'mid_exams',"localField":"stu_id","foreignField":"stu_id","as":"chengji"}},{"$match":{"stu_id":stu_id}}],(err,data)=>{
        if(!err) console.log(data);
        else conosle.log(err);
    });
    // 多表联查 是在后面多个$lookup即可
    res.send(result);
})
module.exports = router;